﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using newsteadWebService.Models;
using newsteadWebService.Areas.Setting.Models;
namespace newsteadWebService.Areas.Setting.Controllers
{
    public class G_UserController : Controller
    {
        //
        // GET: /Setting/G_User/
        private DBDataBase DB = new DBDataBase();
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult SaveData(g_user f)
        {
            if (ModelState.IsValid)
            {
                DB.OpenConnection();
                int id = DB.DBInsert("INSERT INTO g_user(name, username, password, session, status) VALUES ('" + f.name + "', '" + f.username + "', " + f.password + ", " + f.session + ", " + f.status + ") ");
                DB.CloseConnection();
                if (id > 0)
                {
                    ModelState.AddModelError("Success", "Records is effect");
                }
                else
                {
                    ModelState.AddModelError("Error", "Not Success");
                }
            }
            //return RedirectToAction("Index", "User"); 
            return View("Index");
        }

    }
}
